package com.hornsun.repository;

import com.google.common.base.Preconditions;
import com.hornsun.domain.dbo.Member;
import com.hornsun.domain.dbo.MemberExample;
import com.hornsun.repository.mapper.MemberMapper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

import static com.hornsun.util.DESEncryption.DATA_BASE;

/**
 * Created by 编译中... on 2018/2/2.
 */
@Repository
public class MemberRepository {

    @Resource
    private MemberMapper memberMapper;

    /**
     * 手机号查询
     * @param mobile
     * @return
     */
    public List<Member> selectMemberByMobile(String mobile){
        MemberExample memberExample = new MemberExample();
        MemberExample.Criteria criteria = memberExample.createCriteria();
        criteria.andMobileEqualTo(mobile);
        return memberMapper.selectByExample(memberExample);
    }

    /**
     * 插入会员信息
     * @param member
     */
    public void insertMember(Member member){
        int count = memberMapper.insertSelective(member);
        if (count!=1){
            throw new IllegalArgumentException("insert member failed by member:"+member);
        }
    }






}
